﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class exame2_radar : MonoBehaviour
{
    public Transform radarRot;
    public bool radarRun = false;
    public List<GameObject> gunList=new List<GameObject>();
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        gunList.Remove(null);
        if(radarRun)
        {
            radarRot.Rotate(Vector3.up * 45 * Time.deltaTime);
            for (int i = 0; i < gunList.Count; i++)
            {
                if(gunList[i]!=null)
                {
                    var gun= gunList[i].GetComponent<GatlingGun>();
                    if(gun!=null)
                    {
                        gun.enabled = true;
                    }
                }
            }
        }
    }

    private void OnTriggerEnter(Collider other)
    {
        if (other.tag.Equals("Player"))
        {
            var bag = other.GetComponent<exame2_bag>();
            if (bag != null && bag.isHadCard)
            {
                this.radarRun = true;
            }
        }
    }
}
